package com.hghivln.controller.system;

import com.hghivln.pojo.dto.OperLogDto;
import com.hghivln.pojo.vo.AjaxResult;
import com.hghivln.service.OperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotEmpty;

@RestController
@RequestMapping("system/operLog")
public class OperLogController {

    @Autowired
    private OperLogService operLogService;

    /**
     * 分页查询
     */
    @GetMapping("listForPage")
    public AjaxResult listForPage(OperLogDto operLogDto) {
        return operLogService.listForPage(operLogDto);
    }

    /**
     * 删除
     */
    @DeleteMapping("deleteOperLogByIds/{ids}")
    public AjaxResult deleteOperLogByIds(@PathVariable @Validated @NotEmpty(message = "操作日志ID不能为空") Long[] ids) {
        return AjaxResult.success(operLogService.deleteOperLogByIds(ids));
    }

    /**
     * 全部清空
     */
    @DeleteMapping("clearAllOperLog")
    public AjaxResult clearAllOperLog() {
        return AjaxResult.success(operLogService.clearAllOperLog());
    }
}
